package reflection;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

public class Test2 {
    public static void main(String[] args) throws ClassNotFoundException {
        Person p1=new Student();
        Person p2=new Teacher();

        //获取类队象的方式一：getClass()
        Class c1 = p1.getClass();
        System.out.println(c1.hashCode());
        //获取类对象的方式二：forName()
        Class c2=Class.forName("reflection.Student");
        System.out.println(c2.hashCode());
        //获取类对象的方式三： .class
        Class c3 =Student.class;
        System.out.println(c3.hashCode());
        //获取父类的类对象
        Class c4=c3.getSuperclass();
        System.out.println(c4);

        int[] a=new int[10];
        int[] b=new int[100];
        System.out.println(a.getClass().hashCode());
        System.out.println(b.getClass().hashCode());
        System.out.println(a.getClass().equals(b.getClass()));
    }
}
@Setter
@Getter
@ToString
class Person{
    public String name;
}
class Student extends Person{
    public Student(){
        this.name="学生";
    }
}
class Teacher extends Person{
    public Teacher() {
        this.name="老师";
    }
}
